package com.yxjx.duoxue.customview;

import com.yxjx.duoxue.R;
import com.yxjx.duoxue.utils.UIHelper;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;

public class MyProgressDialog extends ProgressDialog {

	public MyProgressDialog(Context context) {
		super(context);
	}
	
	public MyProgressDialog(Context context, int theme) {
		super(context, theme);
	}
	
	/**
	 * 用于会话（登录，提交等）的progress dialog
	 * @param context
	 * @param title
	 * @param message
	 * @return
	 */
	public static ProgressDialog show(Context context, CharSequence title, CharSequence message) {
		ProgressDialog progress = ProgressDialog.show(context, "", "");
		View view = LayoutInflater.from(context).inflate(R.layout.loading_dialog, null);
		progress.setContentView(view, new LinearLayout.LayoutParams(  
                LinearLayout.LayoutParams.MATCH_PARENT,  
                LinearLayout.LayoutParams.MATCH_PARENT));
		UIHelper.setText(view, R.id.loading_text, (String) message);
		return progress;
	}
	
	/**
	 * 用于页面加载progressbar
	 * @param context
	 * @param title
	 * @param message
	 * @return
	 */
	public static ProgressDialog showFullWindow(Context context, CharSequence title, CharSequence message) {
		ProgressDialog progress = ProgressDialog.show(context, "", "");
//		ProgressDialog progress = new ProgressDialog(context);
		View view = LayoutInflater.from(context).inflate(R.layout.loading, null);
		progress.setContentView(view, new LinearLayout.LayoutParams(  
                LinearLayout.LayoutParams.MATCH_PARENT,  
                LinearLayout.LayoutParams.MATCH_PARENT));
		progress.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
		progress.show();
		return progress;
	}
	
	
}
